$("#personalReturn").click(function () {
    var url = "/page/admin/logistList";
    $("#body").load(url);
    setTimeout(function () {
        addDate_logistList(localStorage["pageSize"], localStorage["pageNumber"]);
    }, 300);
});

$("#edit_personal").click(function () {
    load(".student-detail", 500);
    $(this).addClass("hid");
    $(this).next().removeClass("hid");
    $("#name,#phone").parent().removeClass("notAllow");
    // $("#class").parent().removeClass("notAllow");
    $("#name,#phone").removeAttr("disabled");
});


$("#phone").blur(function () {
    var test = /^1[34578]\d{9}$/;
    var phone = $(this).val();
    if (!test.test(phone)) {
        $(this).parent().children(".errorMsg").text("请输入正确的手机号");
    } else {
        $(this).parent().children(".errorMsg").empty();
    }
    if (phone == "") {
        $(this).parent().children(".errorMsg").text("手机号不能为空");
    }
});

$("#name").blur(function () {
    // var test = /^1[34578]\d{9}$/;
    var name = $(this).val();
    // if (!test.test(phone)) {
    //     $(this).parent().children(".errorMsg").text("请输入正确的手机号");
    // } else {
    //     $(this).parent().children(".errorMsg").empty();
    // }
    if (name == "") {
        $(this).parent().children(".errorMsg").text("姓名不能为空");
    } else {
        $(this).parent().children(".errorMsg").text("");
    }
});
$("#update_personal").click(function () {
    var loadDiv = load("#body", 88888);
    var id = localStorage['personalId'];
    var name = $("#name").val();
    var phone = $("#phone").val();
    $.ajax({
        url: "repair/update",
        type: "post",
        data: {
            "token": localStorage['token'],
            "id": id,
            "name": name,
            "phone": phone
        },
        success: function (data) {
            if (data.code === 200) {
                message("请求成功", "更新数据成功", "success", 1500);
                $("#update_personal").attr("disabled", "disabled");
                $("#update_personal").addClass("button_cannot");
                $("#phone,#name").parent().addClass("notAllow");
            } else {
                errorMessage(data.msg);
            }
            load_close(loadDiv)
        }
    })
})
$("#phone ,#name").blur(function () {
    if ($("#phone").parent().children(".errorMsg").text() != "" || $("#name").parent().children(".errorMsg").text() != "") {
        $("#update_personal").attr("disabled", "disabled");
        $("#update_personal").addClass("button_cannot");
    } else {
        $("#update_personal").removeAttr("disabled");
        $("#update_personal").removeClass("button_cannot");
    }
});
